{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.chdir('../')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Save path not found or given and set to default: './save_folder/'. \n",
      "Loading customized repurposing dataset...\n",
      "Beginning Downloading Pretrained Model...\n",
      "Note: if you have already download the pretrained model before, please stop the program and set the input parameter 'pretrained_dir' to the path\n",
      "Downloading finished... Beginning to extract zip file...\n",
      "Pretrained Models Successfully Downloaded...\n",
      "Using pretrained model and making predictions...\n",
      "repurposing...\n",
      "in total: 82 drug-target pairs\n",
      "encoding drug...\n",
      "unique drugs: 81\n",
      "drug encoding finished...\n",
      "encoding protein...\n",
      "unique target sequence: 1\n",
      "protein encoding finished...\n",
      "Done.\n",
      "predicting...\n",
      "---------------\n",
      "Predictions from model 1 with drug encoding MPNN and target encoding CNN are done...\n",
      "-------------\n",
      "repurposing...\n",
      "in total: 82 drug-target pairs\n",
      "encoding drug...\n",
      "unique drugs: 81\n",
      "drug encoding finished...\n",
      "encoding protein...\n",
      "unique target sequence: 1\n",
      "protein encoding finished...\n",
      "Done.\n",
      "predicting...\n",
      "---------------\n",
      "Predictions from model 2 with drug encoding CNN and target encoding CNN are done...\n",
      "-------------\n",
      "repurposing...\n",
      "in total: 82 drug-target pairs\n",
      "encoding drug...\n",
      "unique drugs: 81\n",
      "drug encoding finished...\n",
      "encoding protein...\n",
      "unique target sequence: 1\n",
      "protein encoding finished...\n",
      "Done.\n",
      "predicting...\n",
      "---------------\n",
      "Predictions from model 3 with drug encoding Morgan and target encoding CNN are done...\n",
      "-------------\n",
      "repurposing...\n",
      "in total: 82 drug-target pairs\n",
      "encoding drug...\n",
      "unique drugs: 81\n",
      "drug encoding finished...\n",
      "encoding protein...\n",
      "unique target sequence: 1\n",
      "-- Encoding AAC takes time. Time Reference: 24s for ~100 sequences in a CPU.\t\t\t\t\t Calculate your time by the unique target sequence #, instead of the entire dataset.\n",
      "protein encoding finished...\n",
      "Done.\n",
      "predicting...\n",
      "---------------\n",
      "Predictions from model 4 with drug encoding Morgan and target encoding AAC are done...\n",
      "-------------\n",
      "repurposing...\n",
      "in total: 82 drug-target pairs\n",
      "encoding drug...\n",
      "unique drugs: 81\n",
      "drug encoding finished...\n",
      "encoding protein...\n",
      "unique target sequence: 1\n",
      "-- Encoding AAC takes time. Time Reference: 24s for ~100 sequences in a CPU.\t\t\t\t\t Calculate your time by the unique target sequence #, instead of the entire dataset.\n",
      "protein encoding finished...\n",
      "Done.\n",
      "predicting...\n",
      "---------------\n",
      "Predictions from model 5 with drug encoding Daylight and target encoding AAC are done...\n",
      "-------------\n",
      "models prediction finished...\n",
      "aggregating results...\n",
      "---------------\n",
      "Drug Repurposing Result for SARS-CoV2 3CL Protease\n",
      "+------+----------------------+------------------------+---------------+\n",
      "| Rank |      Drug Name       |      Target Name       | Binding Score |\n",
      "+------+----------------------+------------------------+---------------+\n",
      "|  1   |      Sofosbuvir      | SARS-CoV2 3CL Protease |     190.25    |\n",
      "|  2   |     Daclatasvir      | SARS-CoV2 3CL Protease |     214.58    |\n",
      "|  3   |      Vicriviroc      | SARS-CoV2 3CL Protease |     315.70    |\n",
      "|  4   |      Simeprevir      | SARS-CoV2 3CL Protease |     396.53    |\n",
      "|  5   |      Etravirine      | SARS-CoV2 3CL Protease |     409.34    |\n",
      "|  6   |      Amantadine      | SARS-CoV2 3CL Protease |     419.76    |\n",
      "|  7   |      Letermovir      | SARS-CoV2 3CL Protease |     460.28    |\n",
      "|  8   |     Rilpivirine      | SARS-CoV2 3CL Protease |     470.79    |\n",
      "|  9   |      Darunavir       | SARS-CoV2 3CL Protease |     472.24    |\n",
      "|  10  |      Lopinavir       | SARS-CoV2 3CL Protease |     473.01    |\n",
      "|  11  |      Maraviroc       | SARS-CoV2 3CL Protease |     474.86    |\n",
      "|  12  |    Fosamprenavir     | SARS-CoV2 3CL Protease |     487.45    |\n",
      "|  13  |      Ritonavir       | SARS-CoV2 3CL Protease |     492.19    |\n",
      "|  14  |      Efavirenz       | SARS-CoV2 3CL Protease |     513.81    |\n",
      "|  15  |      Peramivir       | SARS-CoV2 3CL Protease |     538.11    |\n",
      "|  16  |      Amprenavir      | SARS-CoV2 3CL Protease |     602.76    |\n",
      "|  17  |      Telaprevir      | SARS-CoV2 3CL Protease |     607.84    |\n",
      "|  18  |     Grazoprevir      | SARS-CoV2 3CL Protease |     632.54    |\n",
      "|  19  |      Tenofovir       | SARS-CoV2 3CL Protease |     637.96    |\n",
      "|  20  |       Descovy        | SARS-CoV2 3CL Protease |     637.96    |\n",
      "|  21  |     Elvitegravir     | SARS-CoV2 3CL Protease |     654.94    |\n",
      "|  22  |      Atazanavir      | SARS-CoV2 3CL Protease |     679.53    |\n",
      "|  23  |      Nelfinavir      | SARS-CoV2 3CL Protease |     727.49    |\n",
      "|  24  |       Abacavir       | SARS-CoV2 3CL Protease |     738.80    |\n",
      "|  25  | Tenofovir_disoproxil | SARS-CoV2 3CL Protease |     828.19    |\n",
      "|  26  |     Delavirdine      | SARS-CoV2 3CL Protease |     856.06    |\n",
      "|  27  |     Tromantadine     | SARS-CoV2 3CL Protease |     863.40    |\n",
      "|  28  |      Saquinavir      | SARS-CoV2 3CL Protease |     891.75    |\n",
      "|  29  |     Dolutegravir     | SARS-CoV2 3CL Protease |     920.32    |\n",
      "|  30  |     Raltegravir      | SARS-CoV2 3CL Protease |     938.43    |\n",
      "checkout ./save_folder/results_aggregation/repurposing.txt for the whole list\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from DeepPurpose import oneliner\n",
    "from DeepPurpose.dataset import *\n",
    "\n",
    "oneliner.repurpose(*load_SARS_CoV2_Protease_3CL(), *load_antiviral_drugs(no_cid = True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
